import uploadComponent from './upload.vue'
let $vm
export default {
  install (Vue) {
    let Upload = Vue.extend(uploadComponent)
    if (!$vm) {
      $vm = new Upload({el: document.createElement('div')})
      document.body.appendChild($vm.$el)
    }
    const upload = {
      action (event, options) {
        $vm.upload(event, options)
      },
      simple (event, options) {
        return $vm.simpleUpload(event, options)
      }
    }
    Vue.$upload = upload
    Vue.mixin({
      created: function () {
        this.$upload = Vue.$upload
      }
    })
  }
}
